package com.ruoyi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.PurchaseDetailBom;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ErpPurchaseRequestPendingDetailMapper extends BaseMapper<PurchaseDetailBom> {

    // 自定义多表关联查询
//        @Select("SELECT m.doc_type_name, d.request_quantity , m.source_doc, e.parent_material_id,e.parent_material_name,e.specification\n" +
//                "                FROM erp_purchase_request_pending_detail d \n" +
//                "                JOIN erp_purchase_request_management m ON d.purchase_request_id = m.id \n" +
//                "\t\t\t\t\t\t\                t\tjoin erp_product_bom e ON e.parent_material_id=d.bomid\n" +
//                "                where  m.id=1\n")
    //请购表变采购表的请购细目
    @Select("SELECT *from requisition_item a  JOIN erp_material b ON a.material_id=b.id  JOIN  erp_purchase_request_management c ON a.requisition_id=c.id where a.requisition_id=#{id}")
    List<PurchaseDetailBom> selectPurchaseDetailVO(@Param("id") int id);
    //采购表的请购细目


    @Select("select *FROM erp_material")
    List<PurchaseDetailBom> selectmaterials();

    @Select("select *FROM erp_material where id=#{id}")
    List<PurchaseDetailBom> PurchaseDetailId(@Param("id") int id);

    @Delete("delete  FROM requisition_item where requisition_id=#{id} and material_id=#{wid}")
    int deleteDetailId(@Param("id") int id, @Param("wid") int wid);
}

